﻿       @using News__mvc.Models.Database 
@{ 
    //定义变量储存数据库数据
    var news = ViewData["news"] as List<News>;
    var cate = ViewData["cate"] as List<Category>;
    var page = ViewData["page"] as List<Page>;
    

        }
    <!--导航栏-->
<div class="content">
    <div id="nav">
        <div class="nav_main">
            <a href="/Index.html">全部</a>
            @*遍历数据库 循环渲染数据*@
            @{
                foreach (var item in cate)
                {
                    <a href="/Index.html?nid=@item.Id">@item.CateName</a>
                }
            }


            
            <input type="button" value="搜索" id="search">
            <input type="text" id="content" placeholder="请输入查找的内容">
        </div>
    </div>
</div>
<script src="https://code.jquery.com/jquery-3.6.0.min.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
    //点击事件 获取值 跳转页面
    $(function () {
        $("#search").on("click",
            function () {
                window.location.href = './Index.html?word=' + $('#content').val();
            })
    })

</script>



<div class="content">


            <div id="main">
                <ul id="main_ul">
                    @*遍历数据库 循环渲染数据*@
                    @{
                        foreach (var item in news)
                        {
                            <li>

                                <a href="detail.html?id=@item.Id">
                                    <img src="@item.ImgAddress">
                                    <p>@item.Newst</p>
                                    <p>
                                        @item.Newsc
                                    </p>
                                    <p>发布时间:@item.Addtime</p>
                                    <p>@item.Newss</p>
                                </a>


                            </li>

                        }
                    }
                </ul>
            </div>

    <div class="paging">
        <ul class="pagination">
            <li><a href="/Index.html">«</a></li>
            @*遍历数据库 循环渲染数据*@
            @{
                foreach (var item in page)
                {
                    <li><a class="active" href="/Index.html?pageid=@item.Id">@item.PageId</a></li>
                }
            }


            <li><a href="javascript:void(0)">»</a></li>
        </ul>
    </div>

</div>
    <script>

</script>